import TableData from "@/components/public/el-table"; //主页面列表

import TableLyout from '@/components/commonPublic/tableLyout.vue'
import actions from "@/actions";

import {
    getPurveyorDataList, //列表页接口


} from "@/api/request.js";
import publicForm from "@/components/materialDataManage/fromCom.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置

export default {
    name: "supplier",
    data() {
        return {
            name: "supplier",
          
            isLock: false,
            projectId: null,
            projectName: null,
            loading: false,
            btnObj: [], //按钮
            queryCriteriaData: {}, //分页
            searchObj: formJs.searchObj, //搜索条件
            table_config: formJs.table_config, //列表
            radio: "待办",
            // 列表
            getList: {
                page: 1,
                pageSize: 15,
                merchantName: "", //生产厂家
                typ: "2" //"1"材料生产商，"2"材料供应商
            },
            isShow: false, //是否显示弹框

            statusNum: null, //点击那个按钮
            dataFid: null, //列表详情id
            currentRow: null, //列表详情
            activeIndex: "1",
            fId: null, //当前数据fId
            tableData: [],
            companyId: null,
            currentRowId: "",
            dialogTitle: null,
        };
    },
    components: {
        TableLyout,
        publicForm,
        TableData,
       
    },
    mounted() {

        actions.onGlobalStateChange((state, prev) => {
            var data = prev.currentUser.projects;
            this.userInfo = prev.currentUser
        }, true);
        this.yj_searchForm(this.getList);
       
    },
    methods: {
        refreshList(status) { //刷新列表

            if(status==0){
                this.isShow = true;
            }
            this.$nextTick(() => {
                this.yj_searchForm(this.getList);
            })
        },
        closeDialog() {
            this.isShow = false;
        },
        handleRow() {},
      
        getBtnName(name, status) {
            this.statusNum = status
            this.yj_edit(status)
        },

       
        editText() {
            this.isShow = true;
        },

     
        // 查看
        // 点击查看
        yj_viewForm(row, label) {
            if (label == "供应商") {
                this.statusNum = 7
                this.currentRow = row;
                this.isShow = true;
                this.dialogTitle = "材料供应商"


            }
        },
        // 点击当前行变色
        rowChange(val) {
            this.currentRow = val
            this.dataFid = val.fId;
        },
        // 获取列表数据
        yj_searchForm(data) {
            
            // var obj = {
            //     page: 1,
            //     pageSize: 20,
            //     merchantName: "", //生产厂家
            //     typ: "1" //"1"材料生产商，"2"材料供应商
            // }
            this.loading = true;
            var that = this;
            getPurveyorDataList(data)
                .then((res) => {
                    if (res.errcode == 0) {
                        that.loading = false;
                        that.tableData = res.data.pageInfo.list;
                        this.queryCriteriaData = res.data.pageInfo;
                    } else {
                        this.$message.error("列表数据获取失败", res.msg);
                        this.loading = false;
                    }
                })
                .catch((error) => {
                    this.$message.error("列表数据 接口出错", error.msg);
                    this.loading = false;
                });
        },
    },
};